<div class="mws-panel grid_8">
    <div class="mws-panel-header">
        <span class="mws-i-24 i-table-1"><?=$this->pageHeading?></span>
    </div>

    <div class="mws-panel-body">
        <div class="mws-panel-toolbar top clearfix ">
            <ul>
                <li><a class="mws-ic-16 ic-cross" href="javascript:void(0)" title="Delete" onclick="deleteitem()">Delete</a></li>
            </ul>
        </div>
        <!--<table class="mws-table">-->
         <table class="mws-datatable-fn mws-table">
            <thead>
                <tr>
                    <th width="3%">S.No</th>
                    <th width="2%"><input type="checkbox" name="deletebcchk" id="deletebcchk" onclick="if (event.stopPropagation) {
                        event.stopPropagation();
                    }
                    event.cancelBubble = true;return checkall(this)" /></th>
                    <th width="10%">Review Date</th>
                    <th width="10%">Property No.</th>
                    <th width="10%">Name</th>
                    <th width="10%">Customer Rating</th>
                    <th width="10%">Status</th>                    
                   <th width="3%">Edit</th>
                </tr>
            </thead>
            <tbody>
                <?
                $i=0;
				$j=1;
                foreach($this->arrData as $row)
                {
                    $start++;$i++;
                     
					 if($row['review_status']==1){ $image ='tick.png';  }
                    if($row['review_status']==0){ $image ='cross.png';  } 
					 
					 if($cClass=="gradeX odd")
                        {$cClass="gradeX even";}
                    else
                        {$cClass="gradeX odd";}	
                    ?>
                        <tr class="gradeX">
                            <td style="text-align:center"><?=$i;?></td>
                            <td style="text-align:center">
                             <input name='check<?=$j;?>' id='check<?=$j;?>' value='<?=$row['review_id'];?>' 
                                     type='checkbox'>
                                    
                                <script> 
                                    $(document).ready(function(){
                                        $('#bcdel').html(''); 
                                        document.getElementById('deletebcchk').checked = false;
                                    });
                                </script>
                            </td>
                            <td><?=date('d-m-Y',strtotime($row['review_date']))?></td>
                            <td><?=$row['propertycode']?></td>
                            <td><?=$row['guest_name']?></td>
                            <td><?=$row['rating']?></td>                           
                            <td><a id='<?=$start;?>' onclick='changestatus("<?=$row['review_id'];?>","<?=$row['review_status'];?>")' href="javascript:void(0)" >
                                    <img src="<?=APPLICATION_URL_ADMIN;?>css/icons/32/<?=$image;?>"    border='0' height="16" width="16" title='Change Status' alt='Change Status'>
                                </a>
                            </td>
                            <td>
                                <a href="<?=APPLICATION_URL_ADMIN?>property/editreview/reviewId/<?=$row['review_id']?>"><img src="<?=APPLICATION_URL_ADMIN;?>css/icons/32/application_form_edit.png" height="16" width="16"   border='0' title='Edit' alt='Edit'></a>
                            </td>
                           
                        </tr>
                    <?
					$j++;
                }
                ?>
            </tbody>
        </table>
    </div>    	
</div>
<script>
function deleteitem()
{
    var r= "";
    var s="";
    var selected=false;
    var checkedEl = $('table.mws-table tbody input:checkbox:checked:visible:first');
    if(checkedEl.length)
    {    selected = true;
                
        $('table.mws-table tbody input:checkbox:checked:visible').each(function(index,el){
            r += $(this).val()+"|";   
        });   
    }
        
    r += "0";
    if(selected){
        var confirmation = confirm("Are you sure want to delete ?");
        if(confirmation!=true){
            return false;
        }	
	
        $.ajax({ url: "<?= APPLICATION_URL_ADMIN . "property/deletereview" ?>",
            type: "POST",
            data: ({Id:r}),
            success: function(data){			
			
			
                alert('Selected records have been deleted successfully.');
			
                window.location.href=window.location.href;
            }});
    } else {
        alert('Please choose a record to delete.');
    }
}


function checkall(thisid)
{
  var mainEl = $('table.mws-table input:checkbox:visible:first')[0];
    var checkedEl = $('table.mws-table tbody input:checkbox:visible');
    
    checkedEl.each(function(index,el){

        //console.log(mainEl.checked);
        if(mainEl.checked)
            el.checked = true;
        else
            el.checked = false;    
    });   
    
}

function changestatus(Id,Status)
{
    $.ajax({ 
				type: "POST", 
				url: "<?=APPLICATION_URL_ADMIN?>property/changereviewstatus", 
				data: ({Id:Id,Status:Status}),
				cache: false, 
				success: function(data){				 
				  window.location.href=window.location.href;
			    }
		  });
}

</script>